package day230916;

import java.util.Scanner;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/9/16 18:49
 * 匹配子序列的单词数 100%
 */
public class Solution03 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            char[] s = in.nextLine().toCharArray();
            String[] words = in.nextLine().split(",");
            int res = 0; // 记录个数
            for (int i = 0; i < words.length; i++) {
                // 双指针匹配
                int sIndex = 0;
                int wordIndex = 0;
                char[] word = words[i].toCharArray();
                while (sIndex < s.length && wordIndex < word.length) {
                    if (s[sIndex] != word[wordIndex]) {
                        sIndex++;
                    } else {
                        sIndex++;
                        wordIndex++;
                        if (wordIndex == word.length) {
                            res++;
                        }
                    }
                }
            }
            System.out.println(res);
        }
        in.close();
    }
}
